#include <stdarg.h>
#include "DataType.hpp"

const std::string&		DataType::getValueName(unsigned int value) const
{
	return (this -> _typeValues.find(value)) -> second;
}

const std::string&		DataType::getName() const
{
	return this -> _name;
}

unsigned int			DataType::getType() const
{
	return this -> _type;	
}

unsigned int			DataType::addValue(std::string valueName)
{
	unsigned int		nbTypes = this -> _typeValues.size();
	
	this -> _typeValues.insert( std::pair<unsigned int, std::string>(nbTypes, valueName) );
	return nbTypes;
}

void				DataType::addValues(const char* args, ...)
{
	unsigned int		nbTypes = this -> _typeValues.size();
	va_list			list;
	char*			tmp_arg;
	std::string		tmp_name;
	
	va_start(list, args);
	tmp_name = args;
//	std::cout << tmp_name << std::endl;
	this -> _typeValues.insert( std::pair<unsigned int, std::string>(nbTypes, tmp_name) );
	++nbTypes;
	while ((tmp_arg = va_arg(list, char*)) != NULL)
	{
		tmp_name = tmp_arg;
//		std::cout << tmp_name << std::endl;
		this -> _typeValues.insert( std::pair<unsigned int, std::string>(nbTypes, tmp_name) );
		++nbTypes;
	}
	va_end(list);
}

unsigned int			DataType::getValuesCount() const
{
	return this -> _typeValues.size();
}
	
DataType::DataType(unsigned int type, std::string name) : _type(type), _name(name)
{
	
}
